class Solution
{
public:
    string optimalDivision(vector<int> &nums)
    {
        string result = to_string(nums[0]);
        int n = nums.size();
        if (n == 2)
        {
            result += "/";
            result += to_string(nums[1]);
            return result;
        }
        if (n > 2)
        {
            result += "/(";
            result += to_string(nums[1]);
            for (int i = 2; i < n; ++i)
            {
                result += "/";
                result += to_string(nums[i]);
            }
            result += ")";
        }
        return result;
    }
};